package com.dongbo.recorder.screenrecord.utils;

import android.os.CountDownTimer;
import android.widget.TextView;

public class CodeCount extends CountDownTimer {
    public TextView view;

    public CodeCount(long millisInFuture, long countDownInterval, TextView view) {
        super(millisInFuture, countDownInterval);
        this.view = view;
    }

    @Override
    public void onFinish() {
        if(view != null){
            view.setText("重新发送");
            view.setEnabled(true);
        }
    }

    @Override
    public void onTick(long millisUntilFinished) {
        if(view != null) {
            view.setText(millisUntilFinished / 1000 + "秒后重发");
            view.setEnabled(false);
        }
    }

    public void finish(){
        this.cancel();
        view = null;
    }

}
